﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;


namespace StudybotWPF
{
    class SQLclass
    {
        private MySqlConnection connection;
        private string server, database, uid, password;

        public void connect(string ServerFromTextbox, string DatabaseFromTextbox, string UidFromTextbox, string PasswordFromTextbox)
        {
            server = ServerFromTextbox;
            database = DatabaseFromTextbox;
            uid = UidFromTextbox;
            password = PasswordFromTextbox;

            string connectionstring = "SERVER=" + server + ";" + "DATABASE=" + database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
            connection = new MySqlConnection(connectionstring);
        }
        private bool OpenConnection()
        {
            try
            {
                connection.Open();
                return true;
            }
            catch (MySqlException ex)
            {
                return false;
            }

        }
        private bool CloseConnection()
        {
            try
            {
                connection.Close();
                return true;
            }
            catch (MySqlException ex)
            {
                return false;
            }
        }

    }
}
